﻿@{
    ViewBag.Title = "修改收货信息窗口";
}
<form id="form1" class="layui-form">
    <div class="div-content">
        <div class="layui-form-item">
            <label class="layui-form-label">收件人姓名</label>
            <div class="layui-input-block">
                <input type="text" id="txtAcceptName" class="input txt" />
                <span class="Validform_checktip">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所属省市</label>
            <div class="layui-input-block">
                <select id="txtProvince" name="txtProvince" class="select"></select>
                <select id="txtCity" name="txtCity" class="select"></select>
                <select id="txtArea" name="txtArea" class="select"></select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">详细地址</label>
            <div class="layui-input-block">
                <input type="text" id="txtAddress" class="input normal" />
                <span class="Validform_checktip">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮政编码</label>
            <div class="layui-input-block">
                <input type="text" id="txtPostCode" class="input txt" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系手机</label>
            <div class="layui-input-block">
                <input type="text" id="txtMobile" class="input txt" />
                <span class="Validform_checktip">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-block">
                <input type="text" id="txtTelphone" class="input txt" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">电子邮箱</label>
            <div class="layui-input-block">
                <input type="text" id="txtEmail" class="input txt" />
            </div>
        </div>
    </div>
</form>
@section Scripts{
    <script type="text/javascript" src="~/scripts/jquery/PCASClass.js"></script>
    <script type="text/javascript">
        var api = parent.layer.getFrameIndex(window.name); //获取窗体对象
        function submitValue(W) {
            //初始化省市区
            var mypcas = new PCAS("txtProvince,所属省份", "txtCity,所属城市", "txtArea,所属地区");
            var areaArr = $("#spanArea", W.document).text().split(",");
            if (areaArr.length == 3) {
                mypcas.SetValue(areaArr[0], areaArr[1], areaArr[2]);
            }
            $("#txtAcceptName").val($("#spanAcceptName", W.document).text());
            $("#txtAddress").val($("#spanAddress", W.document).text());
            $("#txtPostCode").val($("#spanPostCode", W.document).text());
            $("#txtMobile").val($("#spanMobile", W.document).text());
            $("#txtTelphone").val($("#spanTelphone", W.document).text());
            $("#txtEmail").val($("#spanEmail", W.document).text());
        }

        //提交表单处理
        function submitForm(W) {
            var currDocument = $(document); //当前文档
            //验证表单
            if ($("#txtAcceptName").val() == "") {
                layer.alert('请填写收货人姓名！', {
                    closeBtn: 0
                }, function (index) {
                    $("#txtAcceptName", currDocument).focus();
                    layer.close(index);
                });
                return false;
            }
            if ($("#txtArea").val() == "") {
                layer.alert('请选择所在地区！', {
                    closeBtn: 0
                }, function (index) {
                    $("#txtProvince", currDocument).focus();
                    layer.close(index);
                });
                return false;
            }
            if ($("#txtAddress").val() == "") {
                layer.alert('请填写详细的送货地址！', {
                    closeBtn: 0
                }, function (index) {
                    $("#txtAddress", currDocument).focus();
                    layer.close(index);
                });
                return false;
            }
            if ($("#txtMobile").val() == "" && $("#txtTelphone").val() == "") {
                layer.alert('联系手机或电话至少填写一项！', {
                    closeBtn: 0
                }, function (index) {
                    $("#txtMobile", currDocument).focus();
                    layer.close(index);
                });
                return false;
            }
            //下一步，AJAX提交表单
            var postData = {
                "order_no": $("#spanOrderNo", W.document).text(), "edit_type": "edit_accept_info",
                "accept_name": $("#txtAcceptName").val(), "province": $("#txtProvince").val(),
                "city": $("#txtCity").val(), "area": $("#txtArea").val(), "address": $("#txtAddress").val(),
                "post_code": $("#txtPostCode").val(), "mobile": $("#txtMobile").val(), "telphone": $("#txtTelphone").val(),
                "email": $("#txtEmail").val()
            };
            //发送AJAX请求
            W.sendAjaxUrl(api, postData, "/admin_ajax/edit_order_status");
            return false;
        }
    </script>
}
